<template>
  <div class="app-container">
    <el-drawer
      title="FQC检验记录"
      :visible.sync="visible"
      size="85%"
      :before-close="cancel"
      custom-class="demo-drawer"
    >
      <div style="padding: 20px;">
        <el-table v-loading="loading" :data="routeproductbomList">
          <el-table-column label="序号" align="center" width="50px">
            <template slot-scope="scope">
              <span>{{scope.$index + 1}}</span>
            </template>
          </el-table-column>
          <el-table-column label="送检单号" align="center" width="150px" prop="inspectionNumber"></el-table-column>
          <el-table-column label="工单编号" align="center" width="110px" prop="projectCode" />
          <el-table-column label="产品编号" align="center" width="110px" prop="productCode" />
          <el-table-column label="产品名称" align="center" prop="productName" />
          <el-table-column label="产品规格" align="center" prop="productSpec" />
          <el-table-column label="客户" align="center" prop="clientName"></el-table-column>
          <el-table-column label="合同号" align="center" prop="ftext4"></el-table-column>
          <el-table-column label="技术分解单号" width="120" align="center" prop="ftext1"></el-table-column>
          <el-table-column label="数量" width="100" align="center" prop="quantityDeclared" />
          <el-table-column label="报检时间" align="center" prop="deliveryTime" width="180"></el-table-column>
          <el-table-column label="检验时间" align="center" prop="provingTime" width="180"></el-table-column>
          <el-table-column label="检验结果" align="center" prop="checkResult">
            <template slot-scope="scope">
              <span>{{ scope.row.checkResult == '0' ? '不合格' : scope.row.checkResult == '1'? '合格' :"=="}}</span>
            </template>
          </el-table-column>
          <el-table-column label="检验员" align="center" prop="checkUser"></el-table-column>
          <el-table-column label="操作" align="center" prop="status">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-view"
                @click="handleView(scope.row)"
              >详情</el-button>
            </template>
          </el-table-column>
        </el-table>

        <!-- <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />-->
      </div>
    </el-drawer>
    <Detail v-if="open" ref="detailDialog"></Detail>
  </div>
</template>

  <script>
import { getFQCInfo } from "@/api/mes/qc/fqc";
import Detail from "./details.vue";
export default {
  name: "replenishment",
  components: { Detail },
  props: {
    routeId: null,
    productId: null,
    processId: null,
    optType: null,
    buttonType: null,
    workorderId: null
  },
  dicts: ["mes_order_status"],
  data() {
    return {
      // 遮罩层
      loading: false,
      visible: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 产品制程物料BOM表格数据
      routeproductbomList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        workorderId: this.workorderId,
        pageNum: 1,
        pageSize: 10
      }
    };
  },
  created() {
    // this.getList();
  },

  methods: {
    init(row) {
      this.visible = true;
      this.queryParams.id = row.id;
      this.getList(row);
    },
    /** 查询产品制程物料BOM列表 */
    getList(row) {
      this.loading = true;
      getFQCInfo(row.id).then(response => {
        this.routeproductbomList = response.data;
        this.loading = false;
      });
    },
    //点击生成领料单中的编号展示详情
    handleView(row) {
      this.open = true;
      console.log(row, "领料单编号的row");
      this.$nextTick(() => {
        this.$refs.detailDialog.init(row);
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.recordId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    cancel() {
      this.visible = false;
      this.routeproductbomList = [];
    }
  }
};
</script>
